<template>
  <div class="behavior">
    <section class="behavior__bread-crumb">
      <BreadCrumb
        v-model:dateRange="dateRange"
        :show-date="true"
        @change="dateChange"
      />
    </section>
    <section class="base-page-container behavior__search">
      <PanelLabelItem label="事件">
        <el-select v-model="eventSelect" placeholder="不限">
          <el-option
            v-for="item in eventOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </PanelLabelItem>
      <BaseRadioGroupLabelItem
        v-model:select="deviceSelect"
        label="设备"
        :options="deviceOptions"
        @change="deviceChange"
      />
      <BaseRadioGroupLabelItem
        v-model:select="userLabelSelect"
        :no-margin-bottom="true"
        label="用户标签"
        :options="userLabelOptions"
        @change="userLabelChange"
      />
    </section>
    <!-- 图表 -->
    <section class="base-page-container">
      <p class="behavior__sales">
        <span class="behavior__sales__label">最高关注公众号数为<strong class="behavior__sales__value">2,923</strong></span>
        <span class="behavior__sales__label">最低关注公众号数为<strong class="behavior__sales__value">61</strong></span>
      </p>
      <div class="behavior__chart">
        <KLineChart
          width="100%"
          height="236px"
          x-type="date"
          y-type="number"
          :x-data="lineChartXData"
          :y-data="lineChartYData"
          :options="{ showSeriesName: true, seriesName: '关注公众号' }"
        />
      </div>
    </section>
    <!-- 表格 -->
    <section class="base-page-container">
      <KTable v-loading="state.loading" v-bind="tableState" v-on="tableEvent">
      </KTable>
    </section>
  </div>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import BreadCrumb from '@/components/base-bread-crumb/index.vue';
import { BaseRadioGroupLabelItem } from '@/components/base-form';
import { KLineChart } from '@/components/k-charts';
import { PanelLabelItem } from '@/components/base-panel';
import { useTableList } from './hooks/use-table-behavior';
import { deviceOptions, userLabelOptions, eventOptions, lineChartYData, lineChartXData } from './data.ts';
defineOptions({
  name: 'KgjAnalysisBehavior'
});
const { state, tableState, tableEvent } = useTableList({ });
const deviceSelect = ref(0);
// 单选
const deviceChange = (val: string | number | boolean) => {
  console.log(val);
};
const userLabelSelect= ref(0);
const userLabelChange = (val: string | number | boolean) => {
  console.log(val);
};
const eventSelect = ref(null);

//
const dateRange = ref(null);
const dateChange = () => {
  console.log(11);
};
</script>
<style lang="scss" scoped>
.behavior {
  &__title {
    height: 24px;
    margin-bottom: $baseMarginBottom;
    font-size: 16px;
    font-style: normal;
    font-weight: 500;
    line-height: 24px;
    color: #303133;
  }

  &__sales {
    font-size: 14px;
    font-style: normal;
    font-weight: 400;
    line-height: 22px;
    color: #909399;
    letter-spacing: -.01px;

    &__label {
      padding-right: 24px;
    }

    &__value {
      padding-left: 2px;
      font-weight: 500;
      color: #606266;
    }

    &__radio {
      padding-left: 4px;
      font-size: 12px;
      font-style: normal;
      font-weight: 500;
      color: #F56C6C;
      letter-spacing: -.01px;

      &::after {
        display: inline-block;
        margin: -10px 0 0 6px;
        font-size: 14px;
        vertical-align: middle;
        content: '';
        border-color: transparent transparent #F56C6C;
        border-style: solid;
        border-width: 6px 4px;
      }

      &--down {
        color: #67C23A;

        &::after {
          margin-top: 6px;
          border-color: #67C23A transparent transparent;
        }
      }
    }
  }

  &__chart {
    display: flex;
    align-items: center;
    height: 236px;
    margin-top: 16px;

    &__content {
      flex: 1;
    }

    &__tab {
      flex-shrink: 0;
      width: 220px;
      margin-left: 24px;
    }
  }
}
</style>
./hooks/use-table-behavior
